<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-form-item label="受益人名称" prop="syName">
        <el-input v-model="queryParams.syName" placeholder="请输入受益人名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="项目名称" prop="xmName">
        <el-input v-model="queryParams.xmName" placeholder="请输入项目名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['guarantee:bidding:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['guarantee:bidding:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['guarantee:bidding:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['guarantee:bidding:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="biddingList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" type="index" prop="id" >
        <template slot-scope="scope">
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="业务员" align="center" prop="userName" />
      <el-table-column label="状态" align="center">
        <template slot-scope="scope">
          <span>{{ statusDict[scope.row.status] }}</span>
        </template>
      </el-table-column>
      <el-table-column label="受益人名称" align="center" prop="syName" />
      <el-table-column label="受益人类型" align="center" prop="syType" />
      <el-table-column label="项目名称" align="center" prop="xmName" />
      <el-table-column label="项目所在地省" align="center" prop="xmSheng" />
      <el-table-column label="项目所在地市" align="center" prop="xmShi" />
      <el-table-column label="项目所在地" align="center" prop="xmAddress" />
      <el-table-column label="项目类型" align="center" prop="xmType" />
      <el-table-column label="开标时间" align="center" prop="xmKbdate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.xmKbdate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="投标有效期" align="center" prop="xmValidity" />
      <el-table-column label="总费用" align="center" prop="totalMoney" />
      <el-table-column label="返润" align="center" prop="fanMoney" />
      <el-table-column label="扣税" align="center" prop="taxMoney" />
      <el-table-column label="业绩" align="center" prop="yeji" />
      <el-table-column label="出函日期" align="center" prop="bhDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bhDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="230" fixed="right">
        <template slot-scope="scope">
          <el-button v-if="scope.row.status == 0" size="mini" type="text" icon="el-icon-edit"
            @click="handleUpdate(scope.row)" v-hasPermi="['guarantee:bidding:edit']">修改</el-button>
          <el-button v-if="scope.row.status != 0" size="mini" type="text" icon="el-icon-tickets" @click="openDetail(scope.row)"
            >详情</el-button>
          <el-button v-if="scope.row.status == 0" size="mini" type="text" icon="el-icon-delete"
            @click="handleDelete(scope.row)" v-hasPermi="['guarantee:bidding:remove']">删除</el-button>
          <el-button v-if="scope.row.status == 0" size="mini" type="text" icon="el-icon-edit"
            @click="handleTijiao(scope.row)" v-hasPermi="['guarantee:bidding:edit']">提交</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改投标保函对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1360px" append-to-body>
      <el-form ref="form" :inline="true" :model="form" label-width="180px">
        <!-- 基本信息 -->
        <el-divider content-position="left">基本信息</el-divider>
        <div>
          <el-form-item label="是否补录" prop="isBulu" :rules="{ required: true, message: '请选择', trigger: 'blur' }">
            <el-select class="my_select" v-model="form.isBulu" placeholder="请选择是否补录">
              <el-option label="否" value="否"></el-option>
              <el-option label="是" value="是"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="受益人名称" prop="syName" :rules="{ required: true, message: '请输入', trigger: 'blur' }">
            <el-input v-model="form.syName" placeholder="请输入受益人名称" />
          </el-form-item>
          <el-form-item label="受益人类型" prop="syType" :rules="{ required: true, message: '请选择', trigger: 'blur' }">
            <el-select class="my_select" v-model="form.syType" placeholder="请选择受益人类型">
              <el-option label="民营" value="民营"></el-option>
              <el-option label="上市公司" value="上市公司"></el-option>
              <el-option label="国有" value="国有"></el-option>
              <el-option label="代理公司" value="代理公司"></el-option>
              <el-option label="其他" value="其他"></el-option>
            </el-select>
          </el-form-item>
        </div>

        <div>
          <el-form-item label="项目名称" prop="xmName" :rules="{ required: true, message: '请输入', trigger: 'blur' }">
            <el-input v-model="form.xmName" placeholder="请输入项目名称" />
          </el-form-item>
          <el-form-item label="项目所在省市" prop="xmShengAndShi"
            :rules="{ required: true, message: '请选择', trigger: 'blur' }">
            <el-cascader :options="areaData" class="my_select" v-model="form.xmShengAndShi" @change="handleAreaChange"
              placeholder="请选择项目所在省市"></el-cascader>
          </el-form-item>
          <el-form-item label="项目所在地" prop="xmAddress" :rules="{ required: true, message: '请输入', trigger: 'blur' }">
            <el-input v-model="form.xmAddress" placeholder="请输入项目所在地" />
          </el-form-item>
          <el-form-item label="项目类型" prop="xmType" :rules="{ required: true, message: '请选择', trigger: 'blur' }">
            <el-select class="my_select" v-model="form.xmType" placeholder="请选择项目类型">
              <el-option label="施工" value="施工"></el-option>
              <el-option label="采购" value="采购"></el-option>
              <el-option label="服务" value="服务"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="是否特殊项目" prop="xmSpecial" :rules="{ required: true, message: '请选择', trigger: 'blur' }">
            <el-select class="my_select" v-model="form.xmSpecial" placeholder="请选择是否特殊项目">
              <el-option label="否" value="否"></el-option>
              <el-option label="世亚行" value="世亚行"></el-option>
              <el-option label="PPP" value="PPP"></el-option>
              <el-option label="重庆" value="重庆"></el-option>
              <el-option label="移动" value="移动"></el-option>
              <el-option label="联通铁塔" value="联通铁塔"></el-option>
              <el-option label="年度投标" value="年度投标"></el-option>
              <el-option label="转开" value="转开"></el-option>
              <el-option label="电文" value="电文"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="开标时间" prop="xmKbdate" :rules="{ required: true, message: '请选择', trigger: 'blur' }">
            <el-date-picker clearable class="my_picker" v-model="form.xmKbdate" type="date" value-format="yyyy-MM-dd"
              placeholder="请选择开标时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="投标有效期" prop="xmValidity" :rules="{ required: true, message: '请选择', trigger: 'blur' }">
            <el-select class="my_select" v-model="form.xmValidity" placeholder="请选择投标有效期">
              <el-option label="60日" value="60日"></el-option>
              <el-option label="90日" value="90日"></el-option>
              <el-option label="120日" value="120日"></el-option>
              <el-option label="180日" value="180日"></el-option>
              <el-option label="年度" value="年度"></el-option>
              <el-option label="其他" value="其他"></el-option>
            </el-select>
          </el-form-item>
        </div>


        <div>
          <el-form-item label="项目的上传文件" prop="xmFileUrl">
            <file-upload v-model="form.xmFileUrl" />
          </el-form-item>
        </div>

        <!-- 企业信息 -->
        <template v-for="(item, index) in form.companyArr">
          <el-divider class="b_divider_tit" content-position="left">
            <span class="divider_tit">企业信息</span>
            <el-button type="primary" size="mini" @click="addCompany()"><i class="el-icon-plus"></i>新增</el-button>
            <el-button v-show="index !== 0" type="danger" size="mini" @click="deleteCompany(index)"><i
                class="el-icon-minus"></i>删除</el-button>
          </el-divider>
          <!-- 基本信息 -->
          <el-divider class="s_divider_tit" content-position="left">基本信息</el-divider>
          <div class="bd_box">
            <el-form-item v-for="(ite, i) in item.xmNameLots" :key="i" label="标段"
              :prop="'companyArr.' + index + '.xmNameLots.' + i" :rules="{
                required: true, message: '请输入', trigger: 'blur'
              }">
              <el-input class="lotInput" v-model="item.xmNameLots[i]" placeholder="请输入内容" />
              <el-button v-if="i + 1 == item.xmNameLots.length" size="small" type="primary" icon="el-icon-plus"
                @click="addLot(index)"></el-button>
              <el-button v-else size="small" type="danger" icon="el-icon-minus" @click="deleteLot(index, i)"></el-button>
            </el-form-item>
          </div>
          <div>
            <el-form-item label="企业名称" :prop="'companyArr.' + index + '.name'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.name" placeholder="请输入企业名称" />
            </el-form-item>
            <el-form-item label="企业所在省市" :prop="'companyArr.' + index + '.qyShengAndShi'"
              :rules="{ required: true, message: '请选择', trigger: 'blur' }">
              <el-cascader :options="areaData" class="my_select" v-model="item.qyShengAndShi"
                @change="(val) => { handleQyAreaChange(val, index) }" placeholder="请选择企业所在省市"></el-cascader>
            </el-form-item>
            <el-form-item label="企业地址" :prop="'companyArr.' + index + '.address'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.address" placeholder="请输入企业地址" />
            </el-form-item>
            <el-form-item label="发票类型" :prop="'companyArr.' + index + '.fpType'"
              :rules="{ required: true, message: '请选择', trigger: 'blur' }">
              <el-select class="my_select" v-model="item.fpType" placeholder="请选择发票类型">
                <el-option label="专票" value="专票"></el-option>
                <el-option label="普票" value="普票"></el-option>
                <el-option label="不开票" value="不开票"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="发票名称" :prop="'companyArr.' + index + '.kpName'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.kpName" placeholder="请输入开票名称" />
            </el-form-item>
            <el-form-item label="发票税号" :prop="'companyArr.' + index + '.kpNum'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.kpNum" placeholder="请输入税号" />
            </el-form-item>
            <el-form-item label="发票电话" :prop="'companyArr.' + index + '.kpPhone'"
              :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.kpPhone" placeholder="请输入开票电话" />
            </el-form-item>
            <el-form-item label="发票地址" :prop="'companyArr.' + index + '.kpAddress'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.kpAddress" placeholder="请输入开票地址" />
            </el-form-item>
            <el-form-item label="发票开户行" :prop="'companyArr.' + index + '.kpBank'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.kpBank" placeholder="请输入开票开户行" />
            </el-form-item>
            <el-form-item label="发票开户账号" :prop="'companyArr.' + index + '.kpBankNum'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.kpBankNum" placeholder="请输入开户账号" />
            </el-form-item>
            <el-form-item label="是否包邮" :prop="'companyArr.' + index + '.freeMail'"
              :rules="{ required: true, message: '请选择', trigger: 'blur' }">
              <el-select class="my_select" v-model="item.freeMail" placeholder="请选择是否包邮">
                <el-option label="是" value="1"></el-option>
                <el-option label="否" value="2"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="邮寄地址" :prop="'companyArr.' + index + '.mailAdress'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.mailAdress" placeholder="请输入邮寄地址" />
            </el-form-item>
            <el-form-item label="营业执照" :prop="'companyArr.' + index + '.yyzzUrl'"
              :rules="{ required: true, message: '请上传', trigger: 'blur' }">
              <file-upload v-model="item.yyzzUrl" />
            </el-form-item>
          </div>

          <!-- 保函信息 -->
          <el-divider class="s_divider_tit" content-position="left">保函信息</el-divider>
          <div>
            <el-form-item label="出函类型" :prop="'companyArr.' + index + '.bhType'"
              :rules="{ required: true, message: '请选择', trigger: 'blur' }">
              <el-select class="my_select" v-model="item.bhType" placeholder="请选择出函类型">
                <el-option label="商保电子" value="商保电子"></el-option>
                <el-option label="商保纸质" value="商保纸质"></el-option>
                <el-option label="银行纸质" value="银行纸质"></el-option>
                <el-option label="银行电子" value="银行电子"></el-option>
                <el-option label="保险电子" value="保险电子"></el-option>
                <el-option label="保险纸质" value="保险纸质"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="出函机构及对接人" :prop="'companyArr.' + index + '.bhJigou'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-select class="my_select" v-model="item.bhJigou" placeholder="请选择出函机构及对接人">
                <el-option
                  v-for="bLetter in bLetters"
                  :key="bLetter.id"
                  :label="bLetter.institution+'('+bLetter.name+')'"
                  :value="bLetter.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="保函金额" :prop="'companyArr.' + index + '.bhMoney'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.bhMoney" placeholder="请输入保函金额" />
            </el-form-item>
            <el-form-item label="保函有效期" :prop="'companyArr.' + index + '.bhValidity'"
                          :rules="{ required: true, message: '请选择', trigger: 'blur' }">

              <el-select class="my_select" v-model="item.bhValidity" placeholder="请输入保函有效期">
                <el-option label="60日" value="60日"></el-option>
                <el-option label="90日" value="90日"></el-option>
                <el-option label="120日" value="120日"></el-option>
                <el-option label="180日" value="180日"></el-option>
                <el-option label="年度" value="年度"></el-option>
                <el-option label="其他" value="其他"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="特殊要求" :prop="'companyArr.' + index + '.bhNotes'"
              :rules="{ required: true, message: '请输入', trigger: 'blur' }">
              <el-input v-model="item.bhNotes" placeholder="请输入特殊要求" />
            </el-form-item>
            <el-form-item label="保函格式" :prop="'companyArr.' + index + '.bhFormat'"
              :rules="{ required: true, message: '请选择', trigger: 'blur' }">
              <el-select class="my_select" v-model="item.bhFormat" placeholder="请选择保函格式">
                <el-option label="独立" value="独立"></el-option>
                <el-option label="独立付条件" value="独立付条件"></el-option>
                <el-option label="一般" value="一般"></el-option>
                <el-option label="连带" value="连带"></el-option>
                <el-option label="无要求" value="无要求"></el-option>
              </el-select>
            </el-form-item>
          </div>
          <!-- 费用信息 -->
          <el-divider class="s_divider_tit" content-position="left">费用信息</el-divider>
          <div>
            <el-form-item label="收费" :prop="'companyArr.' + index + '.fkMoney'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.fkMoney" placeholder="请输入收费" />
            </el-form-item>
            <el-form-item label="有无合作方费用" :prop="'companyArr.' + index + '.fkHzShifou'"
                          :rules="{ required: true, message: '请选择', trigger: 'blur' }">
              <el-select class="my_select" v-model="item.fkHzShifou" @change="(val) => { fkHzChange(val, index) }"
                         placeholder="请选择有无合作方费用">
                <el-option label="无" value="无"></el-option>
                <el-option label="有" value="有"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="item.fkHzShow" label="合作方费用" :prop="'companyArr.' + index + '.fkHzMoney'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.fkHzMoney" placeholder="请输入合作方费用" />
            </el-form-item>
            <el-form-item v-if="item.fkHzShow" label="合作方付款" :prop="'companyArr.' + index + '.fkHzUrl'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.fkHzUrl" placeholder="请输入合作方付款" />
            </el-form-item>
            <el-form-item label="公司收益" :prop="'companyArr.' + index + '.fkShouyi'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.fkShouyi" placeholder="请输入公司收益" />
            </el-form-item>
            <el-form-item label="返润扣税" :prop="'companyArr.' + index + '.fkFanrun'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.fkFanrun" placeholder="请输入返润扣税" />
            </el-form-item>
            <el-form-item label="业绩" :prop="'companyArr.' + index + '.yeji'"
            :rules="[{ required: true, message: '请输入', trigger: 'blur' },{ pattern: /^-?(0|([1-9][0-9]*))(\.[\d]+)?$/, message: '请输入正确格式', trigger: 'blur' }]">
              <el-input v-model="item.yeji" placeholder="请输入业绩" />
            </el-form-item>
            <el-form-item label="付款方式" :prop="'companyArr.' + index + '.fkType'"
                          :rules="{ required: true, message: '请选择', trigger: 'blur' }">
              <el-select class="my_select" v-model="item.fkType" placeholder="请选择付款方式">
                <el-option label="对公（桦）" value="对公（桦）"></el-option>
                <el-option label="财务微信" value="财务微信"></el-option>
                <el-option label="对公（竟融）" value="对公（竟融）"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="付款凭证" :prop="'companyArr.' + index + '.fkUrl'"
                          :rules="{ required: true, message: '请上传', trigger: 'blur' }">
              <file-upload v-model="item.fkUrl" />
            </el-form-item>
          </div>
        </template>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 详情弹窗 -->
    <bidding-detail :form="detailform" :detailOpen="detailOpen" @changeDialog="changeDialog" />
  </div>
</template>

<script>
import { listBidding, getBidding, delBidding, tijiaoBidding, addBidding, updateBidding } from "@/api/guarantee/bidding";
import {getBLetterList} from "@/api/guarantee/letter";
import { pcTextArr } from "element-china-area-data";
import BiddingDetail from '@/views/guarantee/detail/bidding'

export default {
  name: "Bidding",
  components: {
    BiddingDetail
  },
  data() {
    return {
      statusDict: {
        '0': '草稿',
        '2': '主管待审核',
        '4': '业务总待审核',
        '6': '财务待确认',
        '8': '运营待送审',
        '10': '运营待提交',
        '12': '财务核算成本',
        '14': '完成',
        '-1': ' 驳回'
      },
      // 省市数据
      areaData: pcTextArr,
      //出函机构及负责人
      bLetters: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedBBiddingQy: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 投标保函表格数据
      biddingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        status: null,
        syName: null,
        syType: null,
        xmName: null,
        xmSheng: null,
        xmShi: null,
        xmAddress: null,
        xmType: null,
        xmSpecial: null,
        xmSpecialName: null,
        xmKbdate: null,
        xmValidity: null,
        xmFileUrl: null,
        qyId: null,
        acceptanceOpinion: null,
        price: null,
        supplyUrl: null,
        specialRemark: null,
        contractData: null,
        contractHg: null,
        supplyRemark: null,
        totalMoney: null,
        bankMoney: null,
        bankAccount: null,
        bankSf: null,
        bankMoney2: null,
        bankAccount2: null,
        bankSf2: null,
        fanMoney: null,
        taxMoney: null,
        yeji: null,
        sfKp: null,
        bhDate: null,
        mailNum: null,
      },
      // 表单参数
      form: {},
      // 详情弹窗
      detailOpen: false,
      detailform: {}
    };
  },
  created() {
    this.getList();
    this.getBLetters();
  },
  methods: {
    /** 有无合作方费用修改 */
    fkHzChange(val, index) {
      if (val === '有') {
        this.form.companyArr[index].fkHzShow = true
      } else {
        this.form.companyArr[index].fkHzShow = false
      }
    },
    /** 增加企业 */
    addCompany() {
      this.form.companyArr.push({
        xmNameLots: ['']
        // qyName: null,
        // qyId: null,
        // qyShengAndShi: null,
        // qySheng: null,
        // qyShi: null,
        // qyAddress: null
      })
    },
    /** 删除企业 */
    deleteCompany(index) {
      this.form.companyArr.splice(index, 1)
    },
    /** 删除标段 */
    deleteLot(index, i) {
      this.form.companyArr[index].xmNameLots.splice(i, 1)
    },
    /** 添加标段 */
    addLot(index) {
      this.form.companyArr[index].xmNameLots.push('')
    },
    /** 企业省市修改 */
    handleQyAreaChange(value, index) {
      if(value){
        this.form.companyArr[index].sheng = value[0]
        this.form.companyArr[index].shi = value[1]
      }
    },
    /** 省市修改 */
    handleAreaChange(value) {
      this.form.xmSheng = value[0]
      this.form.xmShi = value[1]
    },
    /** 查询投标保函列表 */
    getList() {
      this.loading = true;
      listBidding(this.queryParams).then(response => {
        this.biddingList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        isBulu: null,
        userId: null,
        status: null,
        syName: null,
        syType: null,
        xmName: null,
        xmShengAndShi: null,
        xmSheng: null,
        xmShi: null,
        xmAddress: null,
        xmType: null,
        xmSpecial: null,
        xmSpecialName: null,
        xmKbdate: null,
        xmValidity: null,
        xmFileUrl: null,

        companyArr: [{
          xmNameLots: [''],
          // 合作方费用显示
          fkHzShow: false,
          // qyName: null,
          // qyId: null,
          // qyShengAndShi: null,
          // qySheng: null,
          // qyShi: null,
          // qyAddress: null,
        }],

        acceptanceOpinion: null,
        price: null,
        supplyUrl: null,
        specialRemark: null,
        contractData: null,
        contractHg: null,
        supplyRemark: null,
        totalMoney: null,
        bankMoney: null,
        bankAccount: null,
        bankSf: null,
        bankMoney2: null,
        bankAccount2: null,
        bankSf2: null,
        fanMoney: null,
        taxMoney: null,
        yeji: null,
        sfKp: null,
        bhDate: null,
        mailNum: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    getBLetters(){
      let data  ={};
      getBLetterList().then(response => {
        this.bLetters = response.data;
        console.log(this.bLetters)
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加投标保函";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getBidding(id).then(response => {
        this.form = response.data;
        this.form.xmShengAndShi = [this.form.xmSheng, this.form.xmShi]
        this.form.companyArr.forEach(element => {
          element.qyShengAndShi = [element.sheng, element.shi]
          if (element.fkHzShifou === '有') {
            element.fkHzShow = true
          } else {
            element.fkHzShow = false
          }
        });
        this.open = true;
        this.title = "修改投标保函";
      });
    },
    /** 详情按钮操作 */
    openDetail(row) {
      const id = row.id || this.ids
      getBidding(id).then(response => {
        this.detailform = response.data;
        this.detailform.xmShengAndShi = [this.detailform.xmSheng, this.detailform.xmShi]
        this.detailform.companyArr.forEach(element => {
          element.qyShengAndShi = [element.sheng, element.shi]
          if (element.fkHzShifou === '有') {
            element.fkHzShow = true
          } else {
            element.fkHzShow = false
          }
        });
        this.detailOpen = true;
      });
    },
    changeDialog(val) {
      this.detailOpen = val;
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateBidding(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBidding(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除投标保函编号为"' + ids + '"的数据项？').then(function () {
        return delBidding(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 提交按钮操作 */
    handleTijiao(row) {
      this.$modal.confirm('是否确认提交投标保函项目为"' + row.xmName + '"的数据项？').then(function () {
        return tijiaoBidding(row.id);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("提交成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('guarantee/bidding/export', {
        ...this.queryParams
      }, `bidding_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

<style lang="scss" scoped>
.my_select {
  width: 204px;
}

.my_picker {
  width: 204px;
}

.lotInput {
  width: 150px;
  margin-right: 10px;
}

.bd_box {
  display: flex;
  flex-wrap: wrap;
}

.divider_tit {
  margin-right: 10px;
}

.b_divider_tit {
  margin-bottom: 50px;
}

.s_divider_tit {
  width: 94%;
  margin: 24px 20px;
}
</style>
